package thread;
/**获取线程相关信息的一组方法*/
public class ThreadInfoDemo {
    public static void main(String[] args) {
        Thread t = Thread.currentThread();//获取主线程
        String name = t.getName();//获取线程名字
        System.out.println("name:"+name);
        long id = t.getId();//获取唯一标识
        System.out.println("id:"+id);
        int priority = t.getPriority();//获取线程优先级,1-10,默认5
        System.out.println("priority"+priority);
        boolean isLive = t.isAlive();//线程是否活着
        boolean isDaemon = t.isDaemon();//是否是守护线程
        boolean isInterrupted = t.isInterrupted();//是否被中断
        t.interrupt();
        boolean isInterrupted1 = t.isInterrupted();//是否被中断
        System.out.println("是否活着:"+isLive+",是否是守护线程:"+isDaemon+",是否被中断:"+isInterrupted+",interrupt()后,是否被中断:"+
                isInterrupted1);


    }
}
